<template>
  <div>
    <el-form :inline="true">
      <el-form-item label="计划类型：">
        <el-select v-model="planRecordDTO.planType" placeholder="Select" style="width: 240px">
          <el-option v-for="item in allPlanType" :key="item" :label="item" :value="item" />
        </el-select>
      </el-form-item>
      <el-form-item label="结算状态">
        <el-input v-model="planRecordDTO.statisticsStatus" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="项目编号：">
        <el-input v-model="planRecordDTO.operationTime" placeholder="请项目编号"></el-input>
      </el-form-item>
      <el-button type="primary" @click="fetchData()">查询</el-button>
      <el-button type="primary" @click="handleEdit('')">重置</el-button>
    </el-form>
    <!--表格组件-->
    <el-table :data="list" style="width: 95%">
      <!--prop 后端返回的json数据的字段名-->
      <el-table-column prop="planType" label="计划类型"></el-table-column>
      <el-table-column prop="projectId" label="项目编号"></el-table-column>
      <el-table-column prop="projectName" label="项目名称"></el-table-column>
      <el-table-column prop="comStatus" label="完成状态"></el-table-column>
      <el-table-column prop="statisticsStatus" label="结算状态"></el-table-column>
      <el-table-column
        fixed="right"   
        label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleDetail(scope.row.planId)" type="text" size="small">详情</el-button>
        <el-button @click="handleUpdate(scope.row.planId)" type="text" size="small">结算</el-button>
      </template>
</el-table-column>
    </el-table>
    <el-pagination
     @size-change="sizeData"
     @current-change="pageData"
     :page-sizes="[3,5,8,10]"
     :page-size="3"
     layout="total, sizes, prev, pager, next, jumper"
     :total="count">
   </el-pagination>
  </div>
</template>
<script>
import financeApi from "@/api/finance";

export default {
  data() {
    return {
      //页面数据
      list: [],
      //查询条件
      planRecordDTO: {
        pageNo: 1,
        pageSize: 3,
        planType: "",
        projectId: "",
        statisticsStatus: "",
      },
      count: 0,
      pojo: {
        status: 1,
      },
      dialogFormVisible: false,
      id: "",
      allPlanType: [],
    };
  },
  created() {
    //在创建vue实例后触发钩子函数
    this.fetchData();
  },
  methods: {
    fetchData() {
      //发起axios请求  获取后端的数据，赋值给模型
      financeApi.paln(this.planRecordDTO).then((response) => {
        this.list = response.data.list;
        this.count = response.data.total;
        console.log("list"+this.list);
      });

      financeApi.planType().then((response) => {
        this.allPlanType = response.data;
        console.log(this.allPlanType);
      });

      financeApi.updatePlan(id).then((response) => {
       
      });

    },

    sizeData(size) {
      this.planRecordDTO.pageSize = size;
      this.fetchData();
    },
    pageData(page) {
      this.planRecordDTO.pageNo = page;
      this.fetchData();
    },
    //新增和修改使用同一个方法打开对话框
    handleEdit() {
      this.dialogFormVisible = true;
      this.planRecordDTO.statisticsStatus="",
      this.planRecordDTO.planRecordDTO.planType="",
      this.planRecordDTO.planRecordDTO.operationTime
    },
    handleUpdate(){

    }

  },
};
</script>